<?php
/*
===========================================================================

  Copyright (c) 2010-2012 DSPWeb Development Team

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see http://www.gnu.org/licenses/

  This file is part of DSPWeb source code

===========================================================================
*/

switch ($id) {
	case 1:
		$regions =  "pos_zone='246' OR pos_zone='234' OR pos_zone='235' OR pos_zone='237'";
		break;
	case 2:
		$regions =  "pos_zone='230' OR pos_zone='231' OR pos_zone='232' OR pos_zone='233'";
		break;
	case 3:
		$regions =  "pos_zone='100' OR pos_zone='101' OR pos_zone='139' OR pos_zone='140' OR pos_zone='141' OR pos_zone='142' OR pos_zone='167' OR pos_zone='190'";
		break;
	case 4:
		$regions =  "pos_zone='102' OR pos_zone='103' OR pos_zone='108' OR pos_zone='193' OR pos_zone='196' OR pos_zone='248'";
		break;
	case 5:
		$regions =  "pos_zone='242' OR pos_zone='240' OR pos_zone='239' OR pos_zone='241' OR pos_zone='238'";
		break;
	case 6:
		$regions =  "pos_zone='6' OR pos_zone=' 161' OR pos_zone='162' OR pos_zone='165' OR pos_zone='5' OR pos_zone='112'";
		break;
	case 7:
		$regions =  "pos_zone='105' OR pos_zone='2' OR pos_zone='149' OR pos_zone='195' OR pos_zone='104' OR pos_zone='150' OR pos_zone='1'";
		break;
	case 8:
		$regions =  "pos_zone='113' OR pos_zone='201' OR pos_zone='212' OR pos_zone='174' OR pos_zone='128'";
		break;
	case 9:
		$regions =  "pos_zone='146' OR pos_zone='116' OR pos_zone='170' OR pos_zone='145' OR pos_zone='192' OR pos_zone='194' OR pos_zone='169' OR pos_zone='115'";
		break;
	case 10:
		$regions =  "pos_zone='250' OR pos_zone='252' OR pos_zone='176' OR pos_zone='123'";
		break;
	case 11:
		$regions =  "pos_zone='207' OR pos_zone='211' OR pos_zone='160' OR pos_zone='205' OR pos_zone='163' OR pos_zone='159' OR pos_zone='124'";
		break;
	case 12:
		$regions =  "pos_zone='209' OR pos_zone='114' OR pos_zone='168' OR pos_zone='208' OR pos_zone='247' OR pos_zone='125'";
		break;
	case 13:
		$regions =  "pos_zone='24' OR pos_zone='25' OR pos_zone='31' OR pos_zone='27' OR pos_zone='30' OR pos_zone='29'OR pos_zone='28' OR pos_zone='32' OR pos_zone='26'";
		break;
	case 14:
		$regions =  "pos_zone='207' OR pos_zone='211' OR pos_zone='160' OR pos_zone='205' OR pos_zone='163' OR pos_zone='159' OR pos_zone='124'";
		break;
	case 15:
		$regions =  "pos_zone='127' OR pos_zone='184' OR pos_zone='157' OR pos_zone='126' OR pos_zone='179' OR pos_zone='158'";
		break;
	case 16:
		$regions =  "pos_zone='246' OR pos_zone='244' OR pos_zone='245' OR pos_zone='243'";
		break;
	case 17:
		$regions =  "pos_zone='191' OR pos_zone='173' OR pos_zone='106' OR pos_zone='143' OR pos_zone='107' OR pos_zone='144' OR pos_zone='172'";
		break;
	case 18:
		$regions =  "pos_zone='181' OR pos_zone='180' OR pos_zone='130' OR pos_zone='178' OR pos_zone='177'";
		break;
	case 19:
		$regions =  "pos_zone='153' OR pos_zone='202' OR pos_zone='154' OR pos_zone='251' OR pos_zone='122' OR pos_zone='121'";
		break;
	case 20:
		$regions =  "pos_zone='4' OR pos_zone='44' OR pos_zone='118' OR pos_zone='213' OR pos_zone='3' OR pos_zone='198' OR pos_zone='249' OR pos_zone='117'";
		break;
	case 21:
		$regions =  "pos_zone='152' OR pos_zone='7' OR pos_zone='8' OR pos_zone='151' OR pos_zone='200' OR pos_zone='119' OR pos_zone='120'";
		break;
	case 22:
		$regions =  "pos_zone='147' OR pos_zone='197' OR pos_zone='109' OR pos_zone='148' OR pos_zone='110'";
		break;
	case 23:
		$regions =  "pos_zone='13' OR pos_zone='12' OR pos_zone='11'";
		break;
	default:
	$regions =  "pos_zone='230' OR pos_zone='231'";
		break;
}

// Setup pagination for max characters per page

$query = $sql->query("SELECT COUNT(*) as num FROM accounts_sessions INNER JOIN chars ON chars.charid=accounts_sessions.charid WHERE ".$regions."");
$res = $sql->fetch_assoc($query);
$total_results = $res['num'];
$total_pages = ceil($total_results/$limit);

if (!empty($_GET['page'])) {
	$page = $sql->smartquote($_GET['page']);
	
	if ($page > $total_pages) {
		$start = 0;
	}
	else {
		$start = ($page - 1) * $limit;
	}
}
else {
	$start = 0;
}

$q = $sql->query("SELECT * FROM accounts_sessions INNER JOIN chars ON chars.charid=accounts_sessions.charid WHERE ".$regions." LIMIT ".$start.",".$limit."");

$page = "views/region_details.php";

?>